package servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Properties;
import java.util.Set;

@WebServlet(name = "Servlet06", value = "/readProp")
public class Servlet06 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletContext ctx = request.getServletContext();
        InputStream is = ctx.getResourceAsStream("/WEB-INF/classes/01.properties");
        Properties prop = new Properties();
        prop.load(is);
        Set<Object> keySet = prop.keySet();
        for (Object o : keySet) {
            String o1 = (String) o;
            String value = prop.getProperty(o1);
            response.setContentType("text/html;charset=utf-8");
            PrintWriter out = response.getWriter();
            out.print("<h1>"+o1+"="+value+"</h1>");
        }


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
